home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / ISSUE09 / X3270-BD / X3270-BD.ZIP / XDEMO.PAS < prev   
Pascal/Delphi Source File  |  1995-07-13  |  8KB  |  273 lines

  1. (******************************************************************************
  2.  
  3.     DEMO x3270 for Borland Delphi
  4.                 Version 2.0
  5.            (all rights reserved)
  6.  
  7.     Software by:
  8.  
  9.             Mauro Tronto
  10.             Via Jesi, 43
  11.             60127 ANCONA (ITALY)
  12.  
  13.             Home: (39)-71-890604
  14.             CompuServe ID: 100103,2660
  15.                         Internet: 100103.2660@compuserve.com
  16.  
  17.                 Date: 11/07/95 21.21.21
  18.  
  19. ******************************************************************************)
  20. program xDemo;
  21.  
  22. uses x3270 in 'x3270.pas'; { Uses of x3270 unit file - T3270 class } ;
  23.  
  24. (*
  25.  *  This is an application framework that interacts with host session(s)
  26.  *  under 3270 emulation software. Look up carefully!
  27.  *)
  28.  var h: T3270;
  29.  
  30. (*
  31.  *  When you start running an application that interacts with host session
  32.  *  you must reset all 3270 system parameters to standard value.
  33.  *)
  34.  HResetSystem;
  35.  
  36. (*
  37.  *  For the first time, you must instantiate an x3270 object that relate to
  38.  *  unique host session shortname, such as "E".
  39.  *  See the example below:
  40.  *)
  41.  h := T3270.Create( 'E' );
  42.  
  43. (*
  44.  *  If you don't know anyone of your shortname sessions, don't worry!
  45.  *  x3270 automatically check your environment and connect to the first
  46.  *  host session available. See the example below:
  47.  *)
  48.  h := T3270.Create( '' );
  49.  
  50. (*
  51.  *   You can now verify the integrity object by testing an instance
  52.  *   variable named > InitOK <.
  53.  *)
  54.  if not h.InitOK then
  55.    h.ShowResult;
  56.  
  57. (*
  58.  *   But..what is the method ShowResult ... ?
  59.  *
  60.  *   After calling any methods, x3270 set an export instance variable named
  61.  *   > Status < that contains an internal object that describe the status
  62.  *   of object itself.
  63.  *
  64.  *   x3270 has an INTERNAL DICTIONARY that contains ALL standard IBM RETURN
  65.  *   CODE AND RELATED EXPLANATIONS.
  66.  *
  67.  *   So, after calling any methods that interact with low-level subsystem,
  68.  *   you can verify return code in the Status.Number property and read a
  69.  *   Status.Description property for detail informations.
  70.  *
  71.  *   Furthermore, there is a method ShowResult that use the instance
  72.  *   variable "status" and show it in a dialog box.
  73.  *)
  74.  h.Status.Number;
  75.  h.Status.Description;
  76.  MessageDlg( h.Status.Description, mtInformation, [mbOK], 0 );
  77.  
  78. (*
  79.  *   Now, you are shure that everythink works fine!
  80.  *   So, you can see for example some host properties that are encapsulated
  81.  *   in your T3270 object. See the example below:
  82.  *)
  83.  h.Shortname              { Shortname of host session }
  84.  h.Longname               { Longname of host session  }
  85.  h.Rows                   { Rows number of 3270 display }
  86.  h.Columns                { Columns number of 3270 display }
  87.  h.SizeOfPS               { Size (bytes) of presentation space }
  88.  
  89. (*
  90.  *   You can check the correct host position where your application
  91.  *   must start by method SearchString that return the host position
  92.  *   where an occurrence of relate string start (otherwise return 0).
  93.  *   See the example below:
  94.  *)
  95.  if h.SearchString( 'ENTER APPLICATION REQUEST' ) = 0 then
  96.    MessageDlg( 'Must be at the VTAM Screen for logging into TSO' ... );
  97.  
  98. (*
  99.  *   You can also specify the position where the searching must start!
  100.  *   See the example below:
  101.  *)
  102.  if not h.SearchAt( 'ENTER APPLICATION REQUEST', 50 ) then
  103.    MessageDlg( 'Must be at the VTAM Screen for logging into TSO' ... );
  104.  
  105. (*
  106.  *   Question: Can i send a string onto host ?
  107.  *             Can i send AID keystrokes, such as PA1, PF3 and so on ?
  108.  *
  109.  *   Yes! You can use methods SendKey and WriteAt().
  110.  *
  111.  *   For AID keystrokes you must use Sendkey while WriteAt() is more
  112.  *   efficient for sending strings onto host.
  113.  *
  114.  *   About AID, all keys are availables by x3270 constants. So you can
  115.  *   relate to KEY_ENTER, KEY_PF3, KEY_PA1 without coding any host sequence.
  116.  *
  117.  *   See the examples below:
  118.  *)
  119.  if h.SendKey( KEY_ENTER ) then            { AID keystroke }
  120.    MessaDlg( 'AID sequence has been sent!' ... );
  121.  
  122.  if h.WriteAt( 'LOGOUT', 50 ) then        { Very efficient method }
  123.    MessaDlg( 'LOGOUT sequence has been sent!' ... );
  124.  
  125. (*
  126.  *   Question: Can i copy all or part of host screen in an application buffer ?
  127.  *
  128.  *   You can use methods CopyScreen and CopyScreenAttr.
  129.  *   Either methods return a char pointer (pChar) to a buffer that contains
  130.  *   host image. You MUST release memory after using it with FreeMem function.
  131.  *
  132.  *   See the examples below:
  133.  *)
  134.  buffer := h.CopyScreen;        { Copy all host screen }
  135.  buffer := h.CopyScreenAttr;        { Copy all host screen with attributes }
  136.   ...
  137.  FreeMem( buffer, Strlen(buffer) + 1 ); { Release memory in global heap }
  138.  
  139. (*
  140.  *   Question: Can i work with host fields ?
  141.  *   There are many methods that allow you to working with host fields.
  142.  *   See the examples below:
  143.  *)
  144.  nPos := h.FieldLocate( 'NU' );
  145.  
  146.  h.FieldGetAt( nPos );
  147.  h.FieldPutAt( 'ciao', nPos );
  148.  h.FieldLengthAt( nPos );
  149.  h.FieldAttributeAt( nPos );
  150.  h.FieldNumericAt( nPos );
  151.  h.FieldCharacterAt( nPos );
  152.  h.FieldProtectedAt( nPos );
  153.  h.FieldUnProtectedAt( nPos );
  154.  h.FieldUpdatedAt( nPos );
  155.  h.FieldHiColorAt( nPos );
  156.  h.FieldLowColorAt( nPos );
  157.  h.FieldSkip;
  158.  
  159. (*
  160.  *   How you can see, you have TOTAL CONTROL over host fields inside your
  161.  *   VO applications.
  162.  *
  163.  *   Perhaps, you can relate to current host CURSOR POSITION instead of
  164.  *   specified position, such as <nPos>. So, if you are working with host
  165.  *   fields, you can use "cursor methods" and relate to fields by actual
  166.  *   host cursor position.
  167.  *
  168.  *   See the examples below:
  169.  *)
  170.  h.CurrentPosition;         { Read host cursor position }
  171.  h.CursorAt( 45 );          { Set/Move host cursor position }
  172.  
  173. (* Refer now to host position 45!
  174.  *)
  175.  h.FieldGet;
  176.  h.FieldPut( 'ciao' );
  177.  h.FieldLength;
  178.  h.FieldAttribute;
  179.  h.FieldNumeric;
  180.  h.FieldCharacter;
  181.  h.FieldProtected;
  182.  h.FieldUnProtected;
  183.  h.FieldUpdated;
  184.  h.FieldHiColor;
  185.  h.FieldLowColor;
  186.  
  187. (*
  188.  *   Question: Can i work with row/pos instead of host position ?
  189.  *             My emulator software show me in the right end corner the
  190.  *             actual host cursor position referred as row/col.
  191.  *             This is very useful!
  192.  *
  193.  *   ALL x3270 methods are based on host position, but there are some
  194.  *   methods that allow you to convert host cursor position to row/col
  195.  *   and vice versa.
  196.  *
  197.  *   See the examples below:
  198.  *)
  199.  h.Row;
  200.  h.Col;
  201.  h.ConvertRowCol( 10,45 );
  202.  
  203. (* So, you can write ...
  204.  *)
  205.  h.WriteAt( 'LOGOUT', h.ConvertRowCol( 10,45 ) );
  206.  
  207. (*
  208.  *   You can control keyboard under Delphi applications.
  209.  *   So, the users cannot modify the status of host sessions while
  210.  *   running the application. See the examples below:
  211.  *)
  212.  h.LockKeyboard;
  213.  h.UnlockKeyboard;
  214.  
  215. (*
  216.  *   You can verify the insert status of host session.
  217.  *   See the examples below:
  218.  *)
  219.  h.InsertMode;
  220.  
  221. (*
  222.  *   You can verify the Caps Lock status of host session.
  223.  *   See the examples below:
  224.  *)
  225.  h.CapsLock;
  226.  
  227. (*
  228.  *   You can verify many other informations by operator information area.
  229.  *   See the examples below:
  230.  *)
  231.  h.OperInfoArea;
  232.  
  233. (*
  234.  *   When application started, whe have calling function ResetSystem().
  235.  *   There are many others functions that allow you to fetch informations
  236.  *   about the configuration environment.
  237.  *
  238.  *   See the examples below:
  239.  *)
  240.  HQuerySessions;
  241.  HQuerySystem;
  242.  
  243. (*
  244.  *   After calling the functions above, you can verify the result by
  245.  *   reading SysNumber and SysDesc environment variables.
  246.  *   This properties allow you to obtain informations as well as the status
  247.  *   property of T3270 object.
  248.  *
  249.  *   See the examples below:
  250.  *)
  251.  if not HResetSystem then
  252.    MessaDlg( SysDesc, mtInformation, [mbOK], 0 );
  253.  
  254. (*
  255.  *  If you have configured your Workstation emulation program for supporting
  256.  *  more than one host sessions, you can instatiate more than one T3270
  257.  *  object with a unique shortname, such as "E" or "F".
  258.  *  Than, you can work with us SIMULTANEOUSLY!
  259.  *  See the example below:
  260.  *)
  261.  host_e := T3270.Create( 'E' );
  262.  host_f := T3270.Create( 'F' );
  263.  
  264.  host_e:SendKey( KEY_ENTER );
  265.  host_f:SendKey( KEY_CLEAR );
  266.  
  267. (*
  268.  *  Well, at this point we can shutdown this read me file!
  269.  *  Thank you very much for your attentions!
  270.  *  Create fun!
  271.  *)
  272.  h.Disconnect; h.Free;
  273.